package com.hsjk.szwj.module.member.controller.admin.user;

import com.hsjk.szwj.framework.common.pojo.CommonResult;
import com.hsjk.szwj.framework.common.pojo.PageResult;
import com.hsjk.szwj.module.member.controller.admin.user.vo.AdminMemberDetailRespVO;
import com.hsjk.szwj.module.member.controller.admin.user.vo.AdminMemberPageReqVO;
import com.hsjk.szwj.module.member.controller.admin.user.vo.AdminMemberRespVO;
import com.hsjk.szwj.module.member.service.user.MemberUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static com.hsjk.szwj.framework.common.pojo.CommonResult.success;

/**
 * @author chenjiawei
 * @desc
 * @Date 2023/09/09 23:39
 **/
@Tag(name = "后台管理 - 用户个人中心")
@RestController
@RequestMapping("/member/user")
@Validated
@Slf4j
public class AdminMemberController {
    @Resource
    private MemberUserService memberUserService;

    @GetMapping("/page")
    @Operation(summary = "/获得用户信息分页列表")
    @PreAuthorize("@ss.hasPermission('system:member:query')")
    public CommonResult<PageResult<AdminMemberRespVO>> getMemberPage(@Valid AdminMemberPageReqVO reqVO) {
//        return success(memberUserService.getMemberPageList(reqVO));
        // 新修改
        return success(memberUserService.getMemberUserPage(reqVO));
    }

    @GetMapping("/get")
    @Operation(summary = "/获得用户详细信息")
    @PreAuthorize("@ss.hasPermission('system:member:query')")
    public CommonResult<AdminMemberDetailRespVO> getMemberDetailById(@RequestParam("id") Long memberId) {
        return success(memberUserService.getMemberDetailById(memberId));
    }
}
